﻿using System;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Demos.Puzzles.Nqueens
{
    class InteractivePause
    {
        private Line _objetivoAnimacion;

        public InteractivePause()
        {
            _objetivoAnimacion = new Line();
        }

        public void Pause(double duration, EventHandler next)
        {
            var sb1 = new Storyboard();
            var duration1 = new Duration(TimeSpan.FromMilliseconds(duration));
            var myDoubleAnimation1 = new DoubleAnimation {Duration = duration1};

            sb1.Duration = duration1;
            sb1.Children.Add(myDoubleAnimation1);

            Storyboard.SetTargetProperty(myDoubleAnimation1, new PropertyPath("(Canvas.Left)"));
            Storyboard.SetTarget(myDoubleAnimation1, _objetivoAnimacion);

            myDoubleAnimation1.From = 0;
            myDoubleAnimation1.To = 1;

            sb1.Completed += next;
            sb1.Begin();
        }
    }
}
